var skills = ['appr', 'baln', 'bluf'];
var skill_lbls = ['Appraise', 'Balance', 'Bluff'];
var skillmods      = ['rank', 'abil', 'synergy', 'misc'];
var skillmod_lbls  = ['Ranks', 'Ability', 'Synergy', 'Misc'];


function createSkill(id, name)
{
    var spentdiv = document.createElement('div');
        spentdiv.setAttribute('class', 'inbl pad box');
        appendLabeledField(spentdiv, 'pts' + id, 'Spent', '', 4, false, '')
        
    var ret = document.createElement('div');
        appendLabeledField(ret, 'abil' + id,  name, '', 4, false, '');
        appendConnector(ret, '=', NOPAD);
        
        for (i in skillmods)
        {
          appendCaptionedField(ret, id + '_' + skillmods[i], skillmod_lbls[i], '', 4, true, '');
          appendConnector(ret, '+', NOPAD);
        }
        ret.removeChild(ret.lastChild); /*remove trailing "+"*/
   
        ret.appendChild(spentdiv);
        appendListEnder(ret);
    
    return ret;
}

function appendSkill(p, id, name)
{
    var f = createSkill(id, name);
    p.appendChild(f);
}

function createSkillBlock()
{
    var headerdiv = document.createElement('div');
        headerdiv.setAttribute('class', 'inbl pad box');
        appendLabeledField(headerdiv, 'availpts', "Available", '', 4, false, '');
        appendConnector(headerdiv, '=', NOPAD);
        headerdiv.appendChild(createCaptionedField('ptsperlvl', "Per Lvl", '', 4, false, ''));
        

    var ret = document.createElement('div');
        ret.setAttribute('class', 'inbl pad box');        
        ret.appendChild(headerdiv);
        ret.appendChild(createListEnder());
        for (i in skills) {
          appendSkill(ret, skills[i], skill_lbls[i]); }

    return ret;
}

function appendSkillBlock(p)
{ p.appendChild(createSkillBlock()); }

function constructSkillTab()
{
    var p  = document.getElementById('tab-skill');
        if(p.lastChild && p.lastChild.className == 'endls')
        { p.removeChild(p.lastChild); }
        
        appendSkillBlock(p);
        /*appendAttacksBlock(p);*/
        
        p.appendChild(createListEnder());

    /*setupSkillCalcs();*/
}

/* function below to be generated by python */
%(populateSkillTab)s
